/*	
$(document).ready(function() {

			 $(function() {
				  $( "#doc_city" ).autocomplete({
				   source: function(request, response) {
				    $.ajax({
					     url: "/caf/display_cities",
					     data: { term: $("#doc_city").val()},
					     dataType: "json",
					     type: "POST",
					     success: function(data){
					     response(data);
					    }
					   });
				  },
				  minLength:1
				 });
				});
			});
			
$(document).ready(function() {

			 $(function() {
				  $( "#alt_city" ).autocomplete({
				   source: function(request, response) {
				    $.ajax({
					     url: "/caf/display_cities",
					     data: { term: $("#alt_city").val()},
					     dataType: "json",
					     type: "POST",
					     success: function(data){
					     response(data);
					    }
					   });
				  },
				  minLength:1
				 });
				});
			});
			
$(document).ready(function() {

			 $(function() {
				  $( "#loc_city" ).autocomplete({
				   source: function(request, response) {
				    $.ajax({
					     url: "/caf/display_cities",
					     data: { term: $("#loc_city").val()},
					     dataType: "json",
					     type: "POST",
					     success: function(data){
					     response(data);
					    }
					   });
				  },
				  minLength:1
				 });
				});
			});
			
$(document).ready(function() {

			 $(function() {
				  $( "#loc_addr_area" ).autocomplete({
				   source: function(request, response) {
				    $.ajax({
					     url: "/caf/display_areas",
					     data: { term: $("#loc_addr_area").val()},
					     dataType: "json",
					     type: "POST",
					     success: function(data){
					     response(data);
					    }
					   });
				  },
				  minLength:1
				 });
				});
			});
	
$(document).ready(function() {

			 $(function() {
				  $( "#alt_addr_area" ).autocomplete({
				   source: function(request, response) {
				    $.ajax({
					     url: "/caf/display_areas",
					     data: { term: $("#alt_addr_area").val()},
					     dataType: "json",
					     type: "POST",
					     success: function(data){
					     response(data);
					    }
					   });
				  },
				  minLength:1
				 });
				});
			});
			
$(document).ready(function() {

			 $(function() {
				  $( "#doc_addr_area" ).autocomplete({
				   source: function(request, response) {
				    $.ajax({
					     url: "/caf/display_areas",
					     data: { term: $("#doc_addr_area").val()},
					     dataType: "json",
					     type: "POST",
					     success: function(data){
					     response(data);
					    }
					   });
				  },
				  minLength:1
				 });
				});
			});
	*/		
$(document).ready(function(){
	   		$(".autobox").autobox();
			});


			
$(function() {
		$( "input:submit, input:reset", "#div_entry" ).button();
		$( "a", "#div_entry" ).click(function() { return false; });
		});
// we need six different combo box..so six different combo code....we can't reuse single combo box...
//this combo for city name...
(function( $ ) {
		$.widget( "ui.combobox_loc_city", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=loc_city name=loc_city_name size=16 />" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#loc_city" ).combobox_loc_city();
		
	});
//this combo for alternate address city
	(function( $ ) {
		$.widget( "ui.combobox_alt_city", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=alt_city name=alt_city_name size=16>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#alt_city" ).combobox_alt_city();
		
	});
	
//this combo for document address city
	(function( $ ) {
		$.widget( "ui.combobox_doc_city", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=doc_city_name name=doc_city size=16>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#doc_city" ).combobox_doc_city();
	});
//this combo box is to display area dropdown in local reference field...
	(function( $ ) {
		$.widget( "ui.combobox_loc_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=loc_area name=loc_area_name size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#loc_area" ).combobox_loc_area();
	});

//this combo box is to display area dropdown in alternate field...
	(function( $ ) {
		$.widget( "ui.combobox_alt_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=alt_area name=alt_area_name size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#alt_area" ).combobox_alt_area();
	});

//this combo box is to display area dropdown in local reference field...
	(function( $ ) {
		$.widget( "ui.combobox_loc_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=loc_area name=loc_area_name size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#loc_area" ).combobox_loc_area();
	});

//this combo box is to display area dropdown in document field...
	(function( $ ) {
		$.widget( "ui.combobox_doc_area", {
			_create: function() {
				var self = this,
					select = this.element.hide(),
					selected = select.children( ":selected" ),
					value = selected.val() ? selected.text() : "";
				var input = this.input = $( "<input id=doc_area name=doc_area_name size=13>" )
					.insertAfter( select )
					.val( value )
					.autocomplete({
						delay: 0,
						minLength: 0,
						source: function( request, response ) {
							var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
							response( select.children( "option" ).map(function() {
								var text = $( this ).text();
								if ( this.value && ( !request.term || matcher.test(text) ) )
									return {
										label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>" ),
										value: text,
										option: this
									};
							}) );
						},
						select: function( event, ui ) {
							ui.item.option.selected = true;
							self._trigger( "selected", event, {
								item: ui.item.option
							});
						},
						change: function( event, ui ) {
							if ( !ui.item ) {
								var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
									valid = false;
								select.children( "option" ).each(function() {
									if ( $( this ).text().match( matcher ) ) {
										this.selected = valid = true;
										return false;
									}
								});
								if ( !valid ) {
									// remove invalid value, as it didn't match anything
									$( this ).val( "" );
									select.val( "" );
									input.data( "autocomplete" ).term = "";
									return false;
								}
							}
						}
					})
					.addClass( "ui-widget ui-widget-content ui-corner-left" );

				input.data( "autocomplete" )._renderItem = function( ul, item ) {
					return $( "<li></li>" )
						.data( "item.autocomplete", item )
						.append( "<a>" + item.label + "</a>" )
						.appendTo( ul );
				};

				this.button = $( "" )
					
					.attr( "tabIndex", -1 )
					.attr( "title", "Show All Cities" )
					.insertAfter( input )
					.button({
						icons: {
							primary: "ui-icon-triangle-1-s"
						},
						text: false
					})
					.removeClass( "ui-corner-all" )
					.addClass( "ui-corner-right ui-button-icon" )
					.click(function() {
						// close if already visible
						if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
							input.autocomplete( "close" );
							return;
						}

						// pass empty string as value to search for, displaying all results
						input.autocomplete( "search", "" );
						input.focus();
					});
			},

			destroy: function() {
				this.input.remove();
				this.button.remove();
				this.element.show();
				$.Widget.prototype.destroy.call( this );
			}
		});
	})( jQuery );

	$(function() {
		$( "#doc_area" ).combobox_doc_area();
	});
//for validation....
$(function() {
		$("#submit_data").click(function(){
		var filled_on = $("#filled_on_date").val();
		var dob = $("#idob").val();
		var cust_name = $("#cust_name").val();
		var fat_name = $("#father_name").val();
		var poi1 = $("#poi_num1").val();
		var poi2 = $("#poi_num2").val();
		var doc_num = $("#doc_addr_num").val();
		var doc_cross = $("#doc_addr_cross").val();
		var doc_area = $("#doc_area").val();
		var doc_city = $("#doc_city").val();
		var doc_pin = $("#doc_pin").val();
		var alt_num = $("#alt_num").val();
		var alt_cross = $("#alt_cross").val();
		var alt_area = $("#alt_area").val();
		var alt_city = $("#alt_city").val();
		var alt_pin = $("#alt_pin").val();
		
		
		
			if(filled_on ==""){
			alert("Please enter filled on date");return false;
			}
			if(dob == "")
			{
			alert("Please enter date of birth ");return false;
			}
			if(cust_name == "" || cust_name == "only text and hypen is allowed" )
			{
			alert("Please enter customer name");return false;	
			}
		
			if( fat_name == "" || fat_name == "only text and hypen is allowed" )
			{
			alert("Please enter father name");return false;	
			}
			if( poi1 == "" || poi1 == "No Special Character, only alpha/numeric")
			{
			alert("Please enter poi number");return false;	
			}
			if(poi2 == "" || poi2 == "No Special Character, only alpha/numeric")
			{
			alert("Please enter poi number");return false;	
			}
			if( doc_num == "" || doc_num == "Door No/Flat No/House No")
			{
			alert("Please enter document address number!");return false;	
			}
			if( doc_cross == "" || doc_cross == "Cross,Main Stage,Block")
			{
			alert("Please enter document address cross field!");return false;	
			}
			if(doc_area == "")
			{
			alert("Please enter document address area field!");return false;	
			}
			if(doc_city == "")
			{
			alert("Please enter document address city name field!");return false;	
			}
			if(doc_pin == "")
			{
			alert("Please enter document address pincode field!");return false;	
			}
			if(alt_num == "" || alt_num == "Door No/Flat No/House No")
			{
			alert("Please enter alternate address number !");return false;	
			}
			if(alt_cross == "" || alt_cross == "Cross,Main Stage,Block")
			{
			alert("Please enter alternate address cross !");return false;	
			}
			if(alt_area == "")
			{
			alert("Please enter alternate address area !");return false;	
			}
			if(alt_city == "")
			{
			alert("Please enter alternate city name !");return false;	
			}
			if(alt_pin == "")
			{
			alert("Please enter alternate pincode !");return false;	
			}
	
		});
	});

		

		$(document).ready(function(){
			$("#state_name").change(function(){
				var src = $(this).val();

			 	$.ajax({
			type: "GET",
			url: "/caf/doc_display_cities/"+ src,

			dataType: "text/html",
			success: function(html){       $("#document_city").html(html);   
							
							$(function() {
						$( "#doc_city" ).combobox_doc_city();
		
						});
						  }
			

			  });

			});
			});
			
	//to display alternate city dropdown list....		
	$(document).ready(function(){
			$("#state_name").change(function(){
				var src = $(this).val();

			 	$.ajax({
			type: "GET",
			url: "/caf/alt_display_cities/"+ src,

			dataType: "text/html",
			success: function(html){       $("#alternate_city").html(html); 
						$(function() {
						$( "#alt_city" ).combobox_alt_city();
		
	});
			    }

			  });

			});
			});
//this is to display cities information in local reference	
	$(document).ready(function(){
			$("#state_name").change(function(){
				var src = $(this).val();

			 	$.ajax({
			type: "GET",
			url: "/caf/loc_display_cities/"+ src,

			dataType: "text/html",
			success: function(html){       $("#span_refer_city").html(html); 
			
		$(function() {
		$( "#loc_city" ).combobox_loc_city();
		
	});
			    }

			  });

			});
			});
			
//validating fields value for numbers only in pincode field
$(document).ready(function(){
$("#alt_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    alert("Only numbers");
    return false;
  }
});

$("#loc_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    alert("Only numbers");
    return false;
  }
});

$("#doc_pin").keypress(function (e)
{

  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    alert("Only numbers");
    return false;
  }
});

});
		
//checking for local reference field's set or not...
$(document).ready(function(){
	$("#loc_pin").blur(function(){	
	var loc_val = $(this).val();
	if(loc_val !="")
	{
		var loc_area = $("#loc_area").val();
		var loc_city = $("#loc_city").val();		
		var loc_addr_cross = $("#loc_addr_cross").val();
		var loc_addr_num = $("#loc_addr_num").val();
		
		
		if(loc_addr_num=="Door No/Flat No/House No" || loc_addr_cross=="Cross,Main Stage,Block")
		{
			alert("Please enter address field!");
			return false;
		}
		
		if(loc_area=="" || loc_city == null || loc_addr_cross == "" || loc_addr_num == "")
		{
			alert("Please enter address field!");
			return false;
		}	
		
		
	}
	});

});
